package com.zhangxx.web.common.util;

import java.io.IOException;

import org.springframework.beans.factory.annotation.Autowired;
/*import org.springframework.web.multipart.MultipartFile;*/

/*import com.github.tobato.fastdfs.domain.StorePath;
import com.github.tobato.fastdfs.proto.storage.DownloadByteArray;
import com.github.tobato.fastdfs.service.FastFileStorageClient;*/

//@Component
public class FastDFSUtils {

    /*@Autowired
    private FastFileStorageClient storageClient;

     */
    /**
     * 文件上传
     * @param file
     * @return
     * @throws IOException
     *//*
	public String uploadFile(MultipartFile file) throws IOException{
		StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize()
				, getExtension(file.getOriginalFilename()), null);
		return getResAccessUrl(storePath);
		
	}
	
	*/
    /**
     * 图片上传并生成缩略图
     *
     * @param file
     * @return
     * @throws IOException
     *//*
	public String uploadImageAndCrtThumbImage(MultipartFile file) throws IOException{
		StorePath storePath = storageClient.uploadImageAndCrtThumbImage(file.getInputStream(), file.getSize()
				, getExtension(file.getOriginalFilename()), null);
		return getResAccessUrl(storePath);
	} 
	
	*/
    /**
     * 文件下载
     * @param filePath
     * @return
     *//*
	public byte[] downloadFile(String filePath){
		StorePath storePath = StorePath.praseFromUrl(filePath);
		DownloadByteArray callback = new DownloadByteArray();
		byte[] content = storageClient.downloadFile(storePath.getGroup(), storePath.getPath(), callback);
		return content;
	}
	
	*//**
     * 文件删除
     * @param filePath
     *//*
	public void deleteFile(String filePath){
		storageClient.deleteFile(filePath);
	}*/

    private String getExtension(String fileName) {
        int location = fileName.lastIndexOf(".");
        return fileName.substring(location + 1);
    }

	/*private String getResAccessUrl(StorePath storePath){
		String domain = "";
		return domain+"/" + storePath.getFullPath();
	}*/
}
